package com.bank.Servlets;

import com.bank.dao.impl.QueryDaoImpl;
import com.bank.model.BankCard;
import com.bank.model.User;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.io.IOException;
@WebServlet("/QueryInfo")
public class QueryServlet extends HttpServlet {
    @Override
    protected void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        request.setCharacterEncoding("utf-8");
        String bankId = request.getParameter("bank_id");

        QueryDaoImpl queryDao=new QueryDaoImpl();
        //获取两个表的对象并传入session
        BankCard bankCard=queryDao.queryTb_Bankcard(bankId);
        Integer cardId = bankCard.getCard_id();
        User user=queryDao.queryTb_User(cardId);


        HttpSession session = request.getSession();
        session.setAttribute("user",user);
        session.setAttribute("bankCard",bankCard);

        response.sendRedirect("queryinfo.jsp");
    }
}
